
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.基本使用 · GitBook电子书</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="吴俭">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../chapter4/" />
    
    
    <link rel="prev" href="../chapter2/" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    1.介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    2.环境准备
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    3.基本使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    4.插件运用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    5.服务部署
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.基本使用</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x521D;&#x59CB;&#x5316;&#x9879;&#x76EE;">&#x521D;&#x59CB;&#x5316;&#x9879;&#x76EE;</h1>
<h4 id="gitbook&#x521D;&#x59CB;&#x5316;"><code>GitBook</code>&#x521D;&#x59CB;&#x5316;</h4>
<p>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x5E76;&#x8FDB;&#x5165;&#x5230;&#x8BE5;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#xFF0C;&#x6267;&#x884C;&#x4E0B;&#x9762;&#x547D;&#x4EE4;&#xFF0C;&#x521D;&#x59CB;&#x5316; <code>GitBook</code> &#x9879;&#x76EE;&#x3002;</p>
<pre><code class="lang-shell">gitbook init
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x521B;&#x5EFA;&#x4E86;<code>SUMMARY.md</code>&#x6587;&#x6863;&#xFF0C;&#x8FD9;&#x662F;&#x7535;&#x5B50;&#x4E66;&#x7684;&#x76EE;&#x5F55;&#x6587;&#x6863;&#x3002;
&#x7136;&#x540E;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>REAMDE.md</code>&#x6587;&#x6863;&#xFF0C;&#x7528;&#x6765;&#x5BF9;&#x8FD9;&#x4E2A;&#x9879;&#x76EE;&#x8FDB;&#x884C;&#x4ECB;&#x7ECD;&#x3002;</p>
<h4 id="npm&#x521D;&#x59CB;&#x5316;"><code>npm</code>&#x521D;&#x59CB;&#x5316;</h4>
<p>&#x6267;&#x884C;&#x4E0B;&#x9762;&#x547D;&#x4EE4;&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x4E3A;<code>npm</code>&#x9879;&#x76EE;&#x3002;</p>
<pre><code class="lang-shell">npm init
</code></pre>
<p>&#x547D;&#x4EE4;&#x4F1A;&#x63D0;&#x793A;&#x8F93;&#x5165;&#x9879;&#x76EE;&#x4FE1;&#x606F;&#xFF0C;&#x53EF;&#x9ED8;&#x8BA4;&#x4E0D;&#x586B;&#x5199;&#xFF0C;&#x76F4;&#x63A5;&#x56DE;&#x8F66;&#x3002;</p>
<p>&#x6700;&#x540E;&#xFF0C;&#x4F1A;&#x663E;&#x793A;&#x914D;&#x7F6E;&#x4FE1;&#x606F;&#xFF0C;&#x8F93;&#x5165;<code>yes</code>&#x56DE;&#x8F66;&#x5373;&#x53EF;&#x521D;&#x59CB;&#x5316;&#x5B8C;&#x6BD5;&#x3002;</p>
<p>&#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x7CFB;&#x7EDF;&#x4F1A;&#x81EA;&#x52A8;&#x5728;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x521B;&#x5EFA;<code>package.json</code>&#x6587;&#x4EF6;&#xFF0C;&#x8FD9;&#x662F;<code>npm</code> &#x9879;&#x76EE;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;</p>
<h4 id="&#x7AE0;&#x8282;&#x914D;&#x7F6E;">&#x7AE0;&#x8282;&#x914D;&#x7F6E;</h4>
<p><code>GitBook</code>&#x4F7F;&#x7528;&#x6587;&#x4EF6;<code>SUNARY.md</code>&#x6765;&#x5B9A;&#x4E49;&#x4E66;&#x672C;&#x7684;&#x7AE0;&#x8282;&#x548C;&#x5B50;&#x7AE0;&#x8282;&#x7684;&#x7ED3;&#x6784;&#x3002;&#x6587;&#x4EF6;<code>SUWARY.md</code>&#x88AB;&#x7528;&#x6765;&#x751F;&#x6210;&#x4E66;&#x672C;&#x5185;&#x5BB9;&#x7684;&#x9884;&#x89C8;&#x8868;&#x3002;</p>
<p><code>SUMMIARY.md</code> &#x7684;&#x683C;&#x5F0F;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x94FE;&#x63A5;&#x5217;&#x8868;&#xFF0C;&#x94FE;&#x63A5;&#x7684;&#x540D;&#x5B57;&#x662F;&#x7AE0;&#x8282;&#x7684;&#x540D;&#x5B57;&#xFF0C;&#x94FE;&#x63A5;&#x7684;&#x6307;&#x5411;&#x662F;&#x7AE0;&#x8282;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#x3002;
&#x5B50;&#x7AE0;&#x8282;&#x88AB;&#x7B80;&#x5355;&#x7684;&#x5B9A;&#x4E49;&#x4E3A;&#x4E00;&#x4E2A;&#x5185;&#x5D4C;&#x4E8E;&#x7236;&#x7AE0;&#x8282;&#x7684;&#x5217;&#x8868;&#x3002;</p>
<pre><code class="lang-markdown"><span class="hljs-section"># Summary</span>

<span class="hljs-bullet">* </span>[<span class="hljs-string">section 1</span>](<span class="hljs-link">section1/README.md</span>)
<span class="hljs-code">    * [example 1](section1/example1.md)</span>
<span class="hljs-code">    * [example 2](section1/example2.md)</span>
<span class="hljs-bullet">* </span>[<span class="hljs-string">section 2</span>](<span class="hljs-link">section2/README.md</span>)
<span class="hljs-code">    * [example 1](section2/example1.md)</span>
</code></pre>
<h1 id="&#x542F;&#x52A8;&#x9879;&#x76EE;">&#x542F;&#x52A8;&#x9879;&#x76EE;</h1>
<p>&#x5728;<code>package.json</code>&#x6587;&#x4EF6;&#x7684;<code>scripts</code>&#x4E2D;&#x914D;&#x7F6E;&#x5982;&#x4E0B;&#x7684;&#x811A;&#x672C;&#x547D;&#x4EE4;&#x2236;</p>
<pre><code class="lang-json"><span class="hljs-string">&quot;scripts&quot;</span>: {
    <span class="hljs-string">&quot;serve&quot;</span> : <span class="hljs-string">&quot;gitbook serve&quot;</span>,
    <span class="hljs-string">&quot;build&quot;</span>: <span class="hljs-string">&quot;gitbook build&quot;</span>
}
</code></pre>
<p>&#x5206;&#x522B;&#x662F;<code>GitBook</code>&#x5728;&#x672C;&#x5730;&#x542F;&#x52A8;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x548C;<code>GitBook</code>&#x6253;&#x5305;&#x6210;<code>HTML</code>&#x9759;&#x6001;&#x6587;&#x4EF6;&#x7684;&#x547D;&#x4EE4;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x672C;&#x5730;&#x6F14;&#x793A;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#x4E0B;&#x9762;&#x547D;&#x4EE4;&#x542F;&#x52A8;&#x3002;</p>
<pre><code class="lang-shell">npm run serve
</code></pre>
<p>&#x8FD9;&#x6761;&#x547D;&#x4EE4;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x6267;&#x884C;&#x4E86;<code>package.json</code>&#x6587;&#x4EF6;&#x7684; <code>scripts</code>&#x4E2D;&#x7684; <code>serve</code>&#x811A;&#x672C;&#xFF0C;&#x5373;gitbook serve &#x3002;
&#x542F;&#x52A8;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x8F93;&#x5165;<code>http:/ / localhost:4000/</code>&#x3002;</p>
<h1 id="&#x5FFD;&#x7565;&#x6587;&#x4EF6;">&#x5FFD;&#x7565;&#x6587;&#x4EF6;</h1>
<p>&#x4EFB;&#x4F55;&#x5728;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5728;&#x6700;&#x540E;&#x751F;&#x6210;&#x7535;&#x5B50;&#x4E66;&#x65F6;&#x90FD;&#x4F1A;&#x88AB;&#x62F7;&#x8D1D;&#x5230;&#x8F93;&#x51FA;&#x76EE;&#x5F55;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x8981;&#x5FFD;&#x7565;&#x67D0;&#x4E9B;&#x6587;&#x4EF6;&#xFF0C;&#x548C;<code>Git</code>&#x4E00;&#x6837;&#xFF0C;<code>GitBook</code>&#x4F1A;&#x4F9D;&#x6B21;&#x8BFB;&#x53D6;<code>.gitignore</code>, <code>.bookignore</code>&#x548C;<code>.ignore</code>&#x6587;&#x4EF6;&#x6765;&#x5C06;&#x4E00;&#x4E9B;&#x6587;&#x4EF6;&#x548C;&#x76EE;&#x5F55;&#x6392;&#x9664;&#x3002;</p>
<h1 id="&#x914D;&#x7F6E;&#x6587;&#x4EF6;">&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h1>
<p><code>GitBook</code>&#x5728;&#x7F16;&#x8BD1;&#x4E66;&#x7C4D;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x8BFB;&#x53D6;&#x4E66;&#x7C4D;&#x6E90;&#x7801;&#x9876;&#x5C42;&#x76EE;&#x5F55;&#x4E2D;&#x7684;<code>book.js</code> &#x6216;&#x8005;<code>book.json</code> &#xFF0C;&#x8FD9;&#x91CC;&#x4EE5;<code>book. js</code>&#x4E3A;&#x4F8B;&#xFF0C;&#x53C2;&#x8003;<a href="https://github.com/GitbookIO/gitbook" target="_blank"><code>GitBook&#x6587;&#x6863;</code></a>&#x53EF;&#x4EE5;&#x77E5;&#x9053;&#xFF0C; <code>book.js</code>&#x5E38;&#x7528;&#x7684;&#x914D;&#x7F6E;&#x5982;&#x4E0B;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-built_in">module</span>.exports = {
    <span class="hljs-comment">//&#x4E66;&#x7C4D;&#x4FE1;&#x606F;</span>
    title: <span class="hljs-string">&apos;&#x4E66;&#x540D;&apos;</span>,
    description:<span class="hljs-string">&apos;&#x63CF;&#x8FF0;&apos;</span>,
    isbn: <span class="hljs-string">&apos;&#x56FE;&#x4E66;&#x7F16;&#x53F7;&apos;</span>,
    author: <span class="hljs-string">&apos;&#x4F5C;&#x8005;&apos;</span>,
    lang: <span class="hljs-string">&apos;zh-cn&apos;</span>,
    <span class="hljs-comment">//&#x63D2;&#x4EF6;&#x5217;&#x8868;</span>
    plugins: [],
    <span class="hljs-comment">//&#x63D2;&#x4EF6;&#x5168;&#x5C40;&#x914D;&#x7F6E;</span>
    pluginsConfig: {},
    <span class="hljs-comment">//&#x6A21;&#x677F;&#x53D8;&#x91CF;</span>
    variables: {
        <span class="hljs-comment">//&#x81EA;&#x5B9A;&#x4E49;</span>
    },
};
</code></pre>
<h1 id="&#x5B89;&#x88C5;&#x7F16;&#x8F91;&#x5668;">&#x5B89;&#x88C5;&#x7F16;&#x8F91;&#x5668;</h1>
<p><code>GitBook</code>&#x7F16;&#x5199;&#x53EF;&#x4EE5;&#x7528;&#x4EFB;&#x4F55;&#x6587;&#x672C;&#x7F16;&#x8F91;&#x5668;&#x3002;&#x5728;&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x5F3A;&#x70C8;&#x5B89;&#x5229;<code>Typora</code>&#x7F16;&#x8F91;&#x5668;&#x3002;<code>Typora</code>&#x7F16;&#x8F91;&#x5668;&#x662F;&#x975E;&#x5E38;&#x597D;&#x7528;&#x7684;<code>Markdown</code>&#x6587;&#x4EF6;&#x7F16;&#x8F91;&#x5668;&#xFF0C;&#x76F4;&#x63A5;&#x8FDB;<code>Typora</code>&#x5B98;&#x7F51;&#x4E0B;&#x8F7D;&#x5BF9;&#x5E94;&#x5E73;&#x53F0;&#x7684;&#x7248;&#x672C;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../chapter2/" class="navigation navigation-prev " aria-label="Previous page: 2.环境准备">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../chapter4/" class="navigation navigation-next " aria-label="Next page: 4.插件运用">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.基本使用","level":"1.3","depth":1,"next":{"title":"4.插件运用","level":"1.4","depth":1,"path":"chapter4/README.md","ref":"chapter4/README.md","articles":[]},"previous":{"title":"2.环境准备","level":"1.2","depth":1,"path":"chapter2/README.md","ref":"chapter2/README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","-search","search-pro","code","expandable-chapters","back-to-top-button","splitter","hide-element"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"splitter":{},"search-pro":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"吴俭","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GitBook电子书","gitbook":"*","description":"GitBook电子书"},"file":{"path":"chapter3/README.md","mtime":"2021-12-11T12:42:27.270Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-12-11T15:38:57.245Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

